﻿package mortal.game.proxy
{
    import Engine.RMI.*;
    import Framework.Util.*;
    import Message.Game.*;
    import Message.Public.*;
    import extend.language.*;
    import flash.utils.*;
    import mortal.common.error.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.model.vo.pet.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.mvc.core.*;

    public class PetProxy extends Proxy
    {
        private var _sharpId:int;

        public function PetProxy()
        {
            return;
        }// end function

        public function getPlayerPetInfo() : void
        {
            rmi.iPetPrx.getPlayerPetInfo_async(new AMI_IPet_getPlayerPetInfo());
            return;
        }// end function

        public function getPetInfo(param1:int, param2:Array) : void
        {
            rmi.iPetPrx.getPetInfo_async(new AMI_IPet_getPetInfo(), param1, param2);
            return;
        }// end function

        public function learnSkill(param1:String, param2:ItemData) : void
        {
            var learnSkillSuccess:Function;
            var uid:* = param1;
            var item:* = param2;
            learnSkillSuccess = function (param1:AMI_IPet_learnSkill) : void
            {
                var _loc_2:Array = null;
                MsgManager.showMouseMsg(Language.getString(20589), MsgRollTipsType.msgRollTips2);
                if (item.itemInfo.color < EColor._EColorOrange)
                {
                    _loc_2 = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(item.itemInfo.group, item.itemInfo.category, item.itemInfo.type, -1, (item.itemInfo.color + 1), -1, item.itemInfo.effectEx);
                    NetDispatcher.dispatchCmd(ServerCommand.PetLearnSkillSuccess, _loc_2[0]);
                }
                return;
            }// end function
            ;
            if (GameMapUtil.curMapState.isPetBreakMap)
            {
                MsgManager.showRollTipsMsg(Language.getString(70343));
                return;
            }
            rmi.iPetPrx.learnSkill_async(new AMI_IPet_learnSkill(learnSkillSuccess), uid, item.uid);
            return;
        }// end function

        public function updateSkillPos(param1:String, param2:int, param3:int) : void
        {
            rmi.iPetPrx.unsealPetSkill_async(new AMI_IPet_unsealPetSkill(), param1, param2, param3);
            return;
        }// end function

        public function randPetSkill(param1:String, param2:int, param3:Boolean, param4:Boolean) : void
        {
            var randPetSkillSuccess:Function;
            var itemUid:* = param1;
            var times:* = param2;
            var useBindPriority:* = param3;
            var autoBuy:* = param4;
            randPetSkillSuccess = function (param1:AMI_IPet_randPetSkill, param2:Array) : void
            {
                MsgManager.showRollTipsMsg(Language.getString(20590));
                NetDispatcher.dispatchCmd(ServerCommand.PetFreshSkillBook, null);
                return;
            }// end function
            ;
            rmi.iPetPrx.randPetSkill_async(new AMI_IPet_randPetSkill(randPetSkillSuccess), itemUid, times, useBindPriority, autoBuy);
            return;
        }// end function

        public function calAttribute(param1:PetCalAttributeVo) : void
        {
            var calAttributeSuccess:Function;
            var $value:* = param1;
            calAttributeSuccess = function (param1:AMI_IPet_calAttribute, param2:SFightAttribute) : void
            {
                NetDispatcher.dispatchCmd(ServerCommand.PetCalAttributeInfo, {cellFight:param2, growth:$value.growth});
                return;
            }// end function
            ;
            rmi.iPetPrx.calAttribute_async(new AMI_IPet_calAttribute(calAttributeSuccess), $value.petUid, $value.talent, $value.growth);
            return;
        }// end function

        public function updateGrowth(param1:PetUpdateGrowthVO) : void
        {
            var refreshGrowthSucceed:Function;
            var refreshGrowthFail:Function;
            var $vlaue:* = param1;
            refreshGrowthSucceed = function (param1:AMI_IPet_refreshGrowth) : void
            {
                NetDispatcher.dispatchCmd(ServerCommand.PetRefreshGrowthBack, true);
                return;
            }// end function
            ;
            refreshGrowthFail = function (param1:Exception) : void
            {
                RMIDispatcher.getInstance().dispatchErrorEvent(param1);
                NetDispatcher.dispatchCmd(ServerCommand.PetRefreshGrowthBack, false);
                return;
            }// end function
            ;
            rmi.iPetPrx.refreshGrowth_async(new AMI_IPet_refreshGrowth(refreshGrowthSucceed, refreshGrowthFail), $vlaue.petUid, $vlaue.autoBuy, $vlaue.items);
            return;
        }// end function

        public function advance(param1:Boolean, param2:Dictionary) : void
        {
            var refreshGrowthSucceed:Function;
            var refreshGrowthFail:Function;
            var autoBuy:* = param1;
            var items:* = param2;
            refreshGrowthSucceed = function (param1:AMI_IPet_advance, param2:int) : void
            {
                NetDispatcher.dispatchCmd(ServerCommand.PetAdvanceBack, true);
                return;
            }// end function
            ;
            refreshGrowthFail = function (param1:Exception) : void
            {
                RMIDispatcher.getInstance().dispatchErrorEvent(param1);
                NetDispatcher.dispatchCmd(ServerCommand.PetAdvanceBack, false);
                return;
            }// end function
            ;
            rmi.iPetPrx.advance_async(new AMI_IPet_advance(refreshGrowthSucceed, refreshGrowthFail), autoBuy, items);
            return;
        }// end function

        public function getAdvanceReward(param1:int) : void
        {
            rmi.iPetPrx.getAdvanceReward_async(new AMI_IPet_getAdvanceReward(this.getAdvanceRewardSucceed), param1);
            return;
        }// end function

        private function getAdvanceRewardSucceed(param1:AMI_IPet_getAdvanceReward, param2:Boolean) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.PetGetAdvanceRewardSucceed, param2);
            return;
        }// end function

        public function learnSkillDirect(param1:String) : void
        {
            rmi.iPetPrx.learnSkillDirect_async(new AMI_IPet_learnSkillDirect(), param1);
            return;
        }// end function

        public function dress(param1:String, param2:String) : void
        {
            rmi.iPetPrx.dress_async(new AMI_IPet_dress(this.dressSuccess, this.dressFail), param1, param2);
            return;
        }// end function

        private function dressSuccess(param1:AMI_IPet_dress) : void
        {
            return;
        }// end function

        public function changeSharp(param1:int) : void
        {
            this._sharpId = param1;
            rmi.iPetPrx.changeShape_async(new AMI_IPet_changeShape(this.sharpSuccess, this.dressFail), param1);
            return;
        }// end function

        private function sharpSuccess(param1:AMI_IPet_changeShape) : void
        {
            Cache.instance.newPet.pet.sharpId = this._sharpId;
            NetDispatcher.dispatchCmd(ServerCommand.PetSharpSuccess, null);
            return;
        }// end function

        private function dressFail(param1:Exception) : void
        {
            MsgManager.showRollTipsMsg(ErrorCode.getErrorStringByCode(param1.code));
            return;
        }// end function

        public function changeShapeCard() : void
        {
            rmi.iPetPrx.changeShapeCard_async(new AMI_IPet_changeShapeCard());
            return;
        }// end function

    }
}
